Skip to content

Conversation

@welkeyever
Copy link
Member

@welkeyever welkeyever commented Jan 13, 2026

What type of PR is this?

feat & optimize

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

为 claude code spec coding 增加一键配置和初始化能力

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
zh(optional):

  1. 增加 claude code 一键集成
  2. 增加 MCP 自动化配置
  3. 修复 hooks 中 return schema 异常
  4. 优化自动化 parse 流程:增加 parse cache(文件变更驱动 + 三分钟兜底);适配更多的场景
  5. 若干文档优化和重构

(Optional) Which issue(s) this PR fixes:

(optional) The PR that updates user documentation:

@welkeyever welkeyever force-pushed the optimize/cc_integrate branch from 207cb08 to f17e1fd Compare January 14, 2026 03:14
@welkeyever welkeyever force-pushed the optimize/cc_integrate branch from 65dc61a to 6a5daeb Compare January 14, 2026 03:35
@welkeyever welkeyever force-pushed the optimize/cc_integrate branch 3 times, most recently from b74cb65 to 0857bb3 Compare January 14, 2026 06:24
@simuleite
Copy link
Contributor

simuleite commented Jan 14, 2026

自动parse是希望保持仓库版本为最新版;1分钟内可能也会有改动
应该在输出的ast文件里面加上parse time字段更好;是否需要parse可以参考Makefile,比对仓库所有代码文件(只看*go, *py *java, *tsx减少范围)的修改时间mtime是否大于这个parse time;没有修改就跳过parse。
(或者只比对git status文件,但这样就需要加上commit hash的概念,避免commit后git status为空)

"RepoVersion":{
    "CommitHash":"513c633",
    "ParseTime":"2026-01-13T11:00:42.136692+08:00" // 考虑到可读性;内部比对是转换为mtime格式高性能比对
}

@welkeyever welkeyever force-pushed the optimize/cc_integrate branch from 0857bb3 to b67c7e2 Compare January 14, 2026 07:03
@welkeyever
Copy link
Member Author

自动parse是希望保持仓库版本为最新版;1分钟内可能也会有改动 应该在输出的ast文件里面加上parse time字段更好;是否需要parse可以参考Makefile,比对仓库所有代码文件(只看*go, *py *java, *tsx减少范围)的修改时间mtime是否大于这个parse time;没有修改就跳过parse。 (或者只比对git status文件,但这样就需要加上commit hash的概念,避免commit后git status为空)

"RepoVersion":{
    "CommitHash":"513c633",
    "ParseTime":"2026-01-13T11:00:42.136692+08:00" // 考虑到可读性;内部比对是转换为mtime格式高性能比对
}

加了一个新的机制:

  1. 对 cc 的 write 挂了一个 hook,只要 cc 修改文件,下一次查询就会触发主动更新;
  2. 原来的 1 min 定时更新,修改为 3 min 定时更新,作为低频兜底策略

@welkeyever welkeyever force-pushed the optimize/cc_integrate branch from 0a809a0 to bf52b07 Compare January 14, 2026 09:10
@simuleite
Copy link
Contributor

simuleite commented Jan 14, 2026

后来深入研究一下Claude的Hook
图片
发现只有Hook执行出错的stderr会真的传送给Claude。(可能Claude对Hook的定义不是注入上下文,而是做一些权限控制、参数检查)
图片
Hook运行成功,只会提示给用户,不会真的发送给Claude
图片

另一种情况是PreToolUse的block reason会发送给Claude,但是这个操作同样会block阻止工具。
图片

所以后面重新写了Hook,也优化了格式,让它更规范,可以通过常量开关日志;
不过有一个问题是会error两次,还没想到是什么原因。
下面的脚本能够稳定blocking err。Hook的路径还需要修改一下,写法会更清晰一点。其他想要通过blocking err发送给Claude的消息都可以用同样的格式写;如果是命令行,只需要手动写一个脚本匹配command就可以了
abcoder-workflow.md
prompt.sh
reminder.md
reminder.sh
或者用一个极简脚本

#!/bin/bash

# 1. 定义Prompt内容
BLOCK_REASON="User permission denied: Access is restricted by policy."

# 2. 使用 jq 构建返回结果,稳定触发 blocking err
jq -n \
  --arg reason "$BLOCK_REASON" \
  '{
        "decision": "block",
        "reason": $reason,
        "hookSpecificOutput": {
            "hookEventName": "PostToolUse"
        }
    }'

exit 0
图片

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants